import gugga.application.ApplicationController;
import gugga.application.NavigationManager;
import gugga.navigation.MenuNavigation;
import gugga.navigation.NavigationButton;

/**
 * @author bony 
 */
class simpleSite.Application extends ApplicationController {
	
	//List all of the application's fields here. 
	private var mMainNavigation:MenuNavigation;
	private var mHomeButton:NavigationButton; 
	private var mInfoButton:NavigationButton; 
	
	public function Application() 
	{
		// The constructor of the super class must be called.
		super();
		
		// The function getComponent creates a mapping between the instances on the scene and
		// the member variables of the Application class.
		mMainNavigation = getComponent("menuNavigation");
	}
	
	// All Objects instantiated inside the Application inherit UIComponentEx except macromedia components.
	// This function is required because we have to make sure that 
	// all objects inside the Application are associated with their respective classes and are avaialable and ready to work.
	// All sections are phisically nested inside the main Application and their initialization is not immediate.
	// Before execution of that function you cannot call any event related methods or mixin related methods of the objects.
	
	public function initUI ()
	{
		// Call the inherited ApplicationController's initUI()
		super.initUI();
		
		// Configure main navigation.
		configureMenu();
		
		// Register all the sections in the application.
		registerSections();
		
		// Open default section.		
		openSection("About");
		
		NavigationManager.Instance.startNavigations();
		
		// Set navigation state. Should be set only the first time.
		NavigationManager.Instance.startNavigations();
		NavigationManager.Instance.markNavigations("About");
		
		// Initialization sequence	
		// Triger initializing sequence.
		initialize();				
		
		// Activating sequence		
		// Using default activating sequence.
		
		// Open sequence		
		// Using default open sequence.
		
		// Close sequence		
		// Using default close sequence.        	
	}

	private function registerSections ()
	{
		this.registerChildSection("AboutSection","About");
		this.registerChildSection("WhySection","Why");
	}
	
	private function configureMenu ()
	{
		mMainNavigation.registerChildSubItem("btnAbout","About","About");
		mMainNavigation.registerChildSubItem("btnWhy","Why","Why");
		
		NavigationManager.Instance.registerNavigation(mMainNavigation, "MainNavigation");
	}
}